<?php

class Db {
	
	private static $instance = NULL;
	
	/**
	 *
	 * the constructor is set to private so
	 * so nobody can create a new instance using 'new'
	 *
	 */
	private function __construct() {
	/*** maybe set the db name here later ***/
	}
	
	public static function getInstance() {
		
		if (! self::$instance) {
			self::$instance = new PDO ( "mysql:host=localhost;dbname=acm;charset=UTF-8", 'root', 'sbojchuk' );
			self::$instance->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
			self::$instance->exec ( 'SET CHARACTER SET utf8' );
		}
		return self::$instance;
	}
	
	/**
	 *
	 * Like the constructor, we make __clone private
	 * so nobody can clone the instance
	 *
	 */
	private function __clone() {
	}

}

?>
